/**
 *  @file multistateRepresentation.cpp
 *
 *  @date 16-nov-2009
 *  @author Ives van der Flaas
 */

#include "multistateRepresentation.h"
#include <cassert>



void si::MultistateRepresentation::draw(si::Vector2 virtualPosition, si::Vector2 virtualSize)
{
	fRepresentations[static_cast<int>(fCurrentRepresentation)]->draw(virtualPosition, virtualSize);
}



si::StateID si::MultistateRepresentation::changeState(si::StateID newState)
{
	si::StateID tmp = fCurrentRepresentation;
	fCurrentRepresentation = newState;

	return tmp;
}



si::StateID si::MultistateRepresentation::addState(std::tr1::shared_ptr<StaticRepresentation> newRep)
{
	assert(newRep);

	fRepresentations.push_back(newRep);

	// if this is the first representation pushed; make
	// it the default...
	if(fRepresentations.size() == 1)
	{
		fCurrentRepresentation = 0;
	}

	// Although static cast is not strictly necessary,
	// it make's my intentions clear...
	return static_cast<StateID>(fRepresentations.size()-1);
}



void si::MultistateRepresentation::update(double time)
{
}

std::tr1::shared_ptr<si::StaticRepresentation> si::MultistateRepresentation::getState(si::StateID state)
{
	return fRepresentations[state];
}

